﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DynamicChart.Data;

namespace Sinochem.TMS.PurchaseChartService
{
    public class SupplierQuery : IChartDataQuery
    {
        public ChartData GetData(DateRange dateRange, QueryParameter parameter)
        {
            ChartData chart = new ChartData
            {
                Type = ChartType.Column
            };

            if (dateRange.Mode == "y")
            {
                chart.Caption = string.Format("供应商签约前十分析（{0}年）",
                    dateRange.CurrentDate.Year);
            }
            else
            {
                chart.Caption = string.Format("供应商签约前十分析（{0}年{1}月）",
                    dateRange.CurrentDate.Year,
                    dateRange.CurrentDate.Month);
            }

            ChartSeriesData seriesData = new ChartSeriesData();
            chart.SeriesData.Add(seriesData);
            seriesData.Caption = "金额";
            for (int i = 0; i < 10; i++)
            {
                System.Threading.Thread.Sleep(100);
                seriesData.Items.Add(new ChartDataItem
                {
                    Name = "供应商" + i.ToString(),
                    Value = Math.Round((decimal)(new Random().Next(10, 100)),2),
                    NavigationUrl = string.Empty
                });
            }

            return chart;
        }
    }
}
